package com.ellwood.IPGuard.business.system.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @ProjectName: IPGuard-boot
 * @PackageName: com.ellwood.IPGuard.business.system.enums
 * @ClassName: UserSexEnum
 * @Description: // 用户性别状态
 * @Author: Ellwood
 * @CreateDate: 2024/10/14 - 下午1:33
 * @Version: V1.0.0
 */
@Getter
@AllArgsConstructor
public enum UserSexEnum {
        
        /**
         * 男
         */
        MAN(0, "男"),
        /**
         * 女
         */
        WOMEN(1, "女"),
        /**
         * 未知
         */
        UNKNOWN(2,"未知");
        
        private final int value;
        private final String name;
        
        public static String getNameByValue(int value) {
                for (UserSexEnum s : UserSexEnum.values()) {
                        if (s.getValue()==value) {
                                return s.getName();
                        }
                }
                return "";
        }
        
        public static Integer getValueByName(String name) {
                for (UserSexEnum s : UserSexEnum.values()) {
                        if (Objects.equals(s.getName(), name)) {
                                return s.getValue();
                        }
                }
                return null;
        }
}
